package com.wulinbus.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.fancy.common.utils.StringUtil;
import com.wulinbus.model.CreativeHelperModel;
import com.wulinbus.service.CreativeHelperService;
import com.wulinbus.utils.CasUtil;
@Controller
public class CreativeHelperController {
	
	@Resource
	private CreativeHelperService creativeHelperService;
	/**
	 *创意助手显示
	 */
	@RequestMapping("/creative_helper.html")
	public String creative_helper( @RequestParam(defaultValue = "6") Integer pageSize,@RequestParam(defaultValue = "1") Integer pageIndex,HttpServletRequest request, String keyword,Model model) {
		String uid=CasUtil.getUid(request);
		Integer start = (pageIndex - 1) * pageSize;
		List<CreativeHelperModel> creativeHelperList=creativeHelperService.getCreativeHelperList(keyword, start, pageSize);
		Integer totalCount=creativeHelperService.creativeHelperCount(keyword);
		model.addAttribute("creativeHelperList", creativeHelperList);
		model.addAttribute("totalCount", totalCount);
		model.addAttribute("pageSize", pageSize);
		model.addAttribute("pageIndex", pageIndex);
		model.addAttribute("uid", uid);
		return "page-creative-helper";
	}
	/**
	 *创意助手详情
	 */
	@RequestMapping("/creative_helper_detail.html")
	public String creative_helper_detail(Integer hid,Model model,HttpServletRequest request) {
		String uid=CasUtil.getUid(request);
		CreativeHelperModel creativeHelperModel=creativeHelperService.getCreativeHelperByHid(hid);
		model.addAttribute("creativeHelperModel", creativeHelperModel);
		model.addAttribute("uid", uid);
		return "page-creative-helper-detail";
	}

}
